package com.ruoyi.project.app.queue;

import io.netty.util.HashedWheelTimer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

//@Component
public class RedisConsumerStartupRunner implements ApplicationRunner {

    @Autowired
    private RedisDelayedQueue redisDelayedQueue;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        String businessName = "businessName";
//        redisDelayedQueue.produce(1,businessName,10000);
//        redisDelayedQueue.remove(1,businessName);
//        redisDelayedQueue.produce(2,businessName,5000);
        redisDelayedQueue.produce(3,businessName,3000);
//        HashedWheelTimer
        redisDelayedQueue.consume(businessName,new RedisDelayedQueueCallback<Integer>(){
            @Override
            public void callback(Integer msg) {
                System.out.println("redis callback="+msg);
            }
        });

    }
}